// pages/my/my.js
var app = getApp();
const pathUrl = app.globalData.pathUrl;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {
      nickName: '吴伟泉',
      gender: '1',
      language: 'zh_CN',
      city: 'Quanzhou',
      province: 'Fujian',
      country: 'China',
      avatarUrl: 'https://wx.qlogo.cn/mmopen/vi_32/HjZXA4OLm5Fvnxg2VccR4p5xzF7xGbXBGbL9HrqegWmDEsxqPXBnokqZOkTmxR4qCkkZyo4OnAsRelJw0KUd5g/132'
    },
    proAry: ['发起公证', '活体检测', '电子签名', '收执已阅'],
    tabBars: [{
      name: '未签署',
      index:'0'
    },
    {
      name: '已签署',
      index: '1'

    },
    {
      name: '全部',
      index: '2'

    }
    ],
    orderStatusType: 0,
    list: []

  },
  clickTab: function (e) {
    console.log(e)
    var that = this;
    if (this.data.orderStatusType === e.currentTarget.dataset.index) {
      return false;
    } else {
      wx.showLoading({
        title: '加载中',
      })
      that.setData({
        orderStatusType: e.currentTarget.dataset.index,
        loadingComplete: false, //把“没有数据”设为true，显示  
        loading: false, //把"上拉加载"的变量设为false，隐藏  
        pageNumber: 0,
        list: []
      })
      this.onReachBottom();
    }

  },
  onReachBottom: function () {
    var that = this;
    var pageNumber = that.data.pageNumber + 1;
    var allList = that.data.list;
    if (that.data.orderStatusType=='0'){
      wx.request({
        url: pathUrl + '/gzgl/fxyGzgl02/list',
        data: {
          query07: that.data.orderNo,
          query26: '未签署'
        },
        method: 'GET',
        success:function(e){
          wx.hideLoading();
          console.log(e)
          that.setData({
            list:e.data.result.records
          })
        }
      })
    }
    if (that.data.orderStatusType == '1') {
      wx.request({
        url: pathUrl + '/gzgl/fxyGzgl02/list',
        data: {
          query07: that.data.orderNo,
          query26: '已签署'
        },
        method: 'GET',
        success: function (e) {
          wx.hideLoading();
          console.log(e)
          that.setData({
            list: e.data.result.records
          })
        }
      })
    }
    if (that.data.orderStatusType == '2') {
      wx.request({
        url: pathUrl + '/gzgl/fxyGzgl02/list',
        data: {
          query07: that.data.orderNo,
        },
        method: 'GET',
        success: function (e) {
          wx.hideLoading();
          console.log(e)
          that.setData({
            list: e.data.result.records
          })
        }
      })
    }
  },
  exit:function(e){
    wx.showModal({
      title: '提示',
      content: '请确定退出?',
      success:function(res){
        if (res.confirm) {
          wx.clearStorageSync();
          wx.navigateTo({
            url: '/pages/login/login',
          })
        }else{
          return false
        }
       
      },
    fail:function(){
      return false
    }
    })


  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      var that =this ;
    var userInfo = wx.getStorageSync('userInfo');
    var loginInfo = JSON.parse(wx.getStorageSync('loginInfo'));
    var userId = wx.getStorageSync('userId');
    var telphone = wx.getStorageSync('telphone');
    var orderNo = wx.getStorageSync('orderNo');
    var realName = wx.getStorageSync('realName');

    that.setData({
      userInfo: userInfo,
      userId: userId,
      telphone: telphone,
      orderNo: orderNo,
      realName: realName

    })
    this.onReachBottom();

  },
// { "nickName": "Deserve.", "gender": 1, "language": "zh_CN", "city": "Xiamen", "province": "Fujian", "country": "China", "avatarUrl": "https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKFfJ2HvRqyYN3KRvXOvVIMMk7NlbVKoHszMtWUvGPnPg2cwokKDSgcpNuib6TziaTTaKHaOpWQw68A/132" }
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },
  // clickTab: function (e) {
  //   console.log(e.currentTarget.dataset.index);
  // },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  // onReachBottom: function () {

  // },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})